<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <h1>对象简写</h1>
    <script>
        var nickname='jack'
        var age=20
        var user={
            // 属性名和保存属性值的变量名一致, 可以简写
            nickname,
            age,
            // 方法省略:function
            greet(){
                console.log(`我叫${this.nickname}, 我今年${this.age}岁`);
            }
        }
        console.log(user.nickname,user.age);
        user.greet()
    </script>
</body>
</html>